package cn.flying.cloud.task.service.impl;

import java.io.Serializable;
import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.flying.cloud.base.common.utils.Ft;
import cn.flying.cloud.base.common.vo.PageRequest;
import cn.flying.cloud.base.common.vo.PageResponse;
import cn.flying.cloud.task.entity.CpApplicationInfo;
import cn.flying.cloud.task.mapper.CpApplicationInfoMapper;
import cn.flying.cloud.task.service.CpApplicationInfoService;

/**
 * 申请人信息 服务实现类
 *
 * @author admin
 * @since 2025-03-24 16:11:22
 */
@Service
public class CpApplicationInfoServiceImpl extends ServiceImpl<CpApplicationInfoMapper, CpApplicationInfo> implements CpApplicationInfoService {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    /**
     * 查询总数
     *
     * @param cpApplicationInfo
     * @return
     */
    @Override
    public long countObj(CpApplicationInfo cpApplicationInfo) {
        return this.count(getLambdaQueryWrapper(cpApplicationInfo));
    }

    /**
     * 分页查询申请人信息数据
     *
     * @param request
     * @return
     */
    @Override
    public PageResponse<CpApplicationInfo> getPageList(PageRequest<CpApplicationInfo> request) {
        CpApplicationInfo param = request.getParam();
        LambdaQueryWrapper<CpApplicationInfo> wrapper = getLambdaQueryWrapper(param);
        // wrapper TODO
        Page<CpApplicationInfo> page = this.page(new Page<>(request.getPageNum(), request.getPageSize()), wrapper);
        return new PageResponse<>(page.getTotal(), (int) page.getCurrent(), page.getRecords());
    }

    /**
     * 构建查询对象
     * @param param
     * @return
     */
    private LambdaQueryWrapper<CpApplicationInfo> getLambdaQueryWrapper(CpApplicationInfo param) {
        LambdaQueryWrapper<CpApplicationInfo> wrapper = new LambdaQueryWrapper<>();
        // wrapper TODO
        return wrapper;
    }

    /**
     * 列表查询申请人信息数据
     *
     * @param cpApplicationInfo
     * @return
     */
    @Override
    public List<CpApplicationInfo> getList(CpApplicationInfo cpApplicationInfo) {
        LambdaQueryWrapper<CpApplicationInfo> wrapper = new LambdaQueryWrapper<>();
        // wrapper TODO
        List<CpApplicationInfo> list = this.list(wrapper);
        return list;
    }

    /**
     * 查询申请人信息详情数据
     *
     * @param cpApplicationInfo
     * @return
     */
    @Override
    public CpApplicationInfo getOneObj(CpApplicationInfo cpApplicationInfo) {
        LambdaQueryWrapper<CpApplicationInfo> wrapper = new LambdaQueryWrapper<>();
        // wrapper TODO
        return this.getOne(wrapper);
    }

    /**
     * 根据Id查询申请人信息详情数据
     *
     * @param id
     * @return
     */
    @Override
    public CpApplicationInfo getObjById(Serializable id) {
        return this.getById(id);
    }

    /**
     * 新增申请人信息数据
     *
     * @param cpApplicationInfo
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean createObj(CpApplicationInfo cpApplicationInfo) {
        return this.save(cpApplicationInfo);
    }

    /**
     * 更新申请人信息数据
     *
     * @param cpApplicationInfo
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean updateObj(CpApplicationInfo cpApplicationInfo) {
        return this.saveOrUpdate(cpApplicationInfo);
    }

    /**
     * 删除申请人信息数据
     *
     * @param cpApplicationInfo
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean deleteObj(CpApplicationInfo cpApplicationInfo) {
        LambdaQueryWrapper<CpApplicationInfo> wrapper = new LambdaQueryWrapper<>();
        // wrapper TODO
        return this.remove(wrapper);
    }

    /**
     * 根据Id删除申请人信息数据
     *
     * @param id
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean deleteById(Serializable id) {
        return this.removeById(id);
    }
}
